<script setup>
import axios from "axios";
import instance from "./utils/htttp/index.js";
function  getInfo(){
  instance.get("/user?ID=12345").then((response) => {
    console.log(response);
  })
}
function getInfoParam(){
  instance.get("/user",{
    params:{
      ID: 12345
    }
  }).then((response) => {
    console.log(response);
  })
}
function postInfo() {
  instance.post("/post").then(resp => {
    console.log(resp)
  })
}

function postInfoParam() {
  // 数据会被自动转为json
  instance.post("/post", {
    id: 222,
    username: 'zhangsan',
    age: 18
  }).then(resp => {
    console.log(resp)
  })
}

</script>
<template>
  <button @click="getInfo">GET 请求</button>
  <button @click="getInfoParam">GET 请求 参数</button>
  <button @click="postInfo">POST 请求</button>
  <button @click="postInfoParam">POST 请求 参数</button>
</template>

<style scoped>
</style>
